import axios  from '../config'
import { PROJECT_API_URL } from '../baseURL'

export default {
    //获取所有用户
    getRole(){
      return axios({
          url: PROJECT_API_URL + '/sys/role/list',
          method: "GET",
      })
    },
    //添加
    addRole(role){
      return axios({
        url: PROJECT_API_URL + '/sys/role/add',
        method: "POST",
        data: role,
      })
    },
    //删除
    delete(id){
      return axios({
        url: PROJECT_API_URL + '/sys/role/' +id + '/delete',
        method: "DELETE",
      })
    },
    //设置菜单
    setMenu(roleId,menuIds){
      return axios({
        url: PROJECT_API_URL + '/sys/role/roleMenu/' + roleId,
        method: 'POST',
        data: menuIds
      })
    },
    //查找角色拥有的菜单
    getMenu(roleId) {
      return axios({
        url: PROJECT_API_URL + '/sys/role/getMenu/' + roleId,
        method: 'GET',
      })
    },

    //通过角色编码查找角色
    roleCode(rolecode){
      return axios({
        url: PROJECT_API_URL + '/sys/role/fetch',
        method: 'GET',  
        data: rolecode
      })
    }
    
}